
#ifndef _WDDM_INCLUDE_TRACES_H_
#define _WDDM_INCLUDE_TRACES_H_

#include <wdm.h>
#include <stdarg.h>
#include <stdio.h>

#define TRACE_LEVEL_NONE  0
#define TRACE_LEVEL_FATAL 1
#define TRACE_LEVEL_ERROR 2
#define TRACE_LEVEL_WARN  3
#define TRACE_LEVEL_INFO  4
#define TRACE_LEVEL_DEFAULT TRACE_LEVEL_ERROR

extern UINT32 g_logLevel;
extern UINT32 g_BreakAlways;
#define VBoxGpuDbgBreak() \
    {if (KD_DEBUGGER_ENABLED && !KD_DEBUGGER_NOT_PRESENT && g_BreakAlways) DbgBreakPoint();}

void InitQemuLog(void);

#define LOG_TO_QEMU

#ifdef LOG_TO_QEMU

#include <ntstrsafe.h>

#define QEMU_LOG_MAX_LEN 512

void QemuLogPrint(const char *fmt, ...);

#define QemuLog(fmt, ...) do { \
    QemuLogPrint("[GUEST]: " __FUNCTION__ ": " fmt, ## __VA_ARGS__); \
} while (0)

#else

#define QemuLogPrint(fmt, ...) \
    do { } while (0)
#define QemuLog(fmt, ...) \
    do { } while (0)

#endif

#define _LOGMSG(_l, _f, ...) do {    \
    if (_l <= g_logLevel) {  \
        QemuLog(_f, __VA_ARGS__);   \
    }   \
} while (0)

#define LOGF(...) \
    _LOGMSG(TRACE_LEVEL_FATAL, __VA_ARGS__)
#define LOGE(...) \
    _LOGMSG(TRACE_LEVEL_ERROR, __VA_ARGS__)
#define LOGW(...) \
    _LOGMSG(TRACE_LEVEL_WARN, __VA_ARGS__)
#define LOGI(...) \
    _LOGMSG(TRACE_LEVEL_INFO, __VA_ARGS__)

#endif
